package com.example.habits;

import android.annotation.SuppressLint;
import android.app.Service;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.IBinder;

/**
 * Background service that is sticky. Will always be active in the background.
 * 
 * @author Oskar
 */
public class BackgroundService extends Service {
	IBinder mBinder;

	/**
	 * Starting the service. Here we register the receiver listening for unlocks.
	 */
	@SuppressLint("NewApi") @Override
	public int onStartCommand(Intent intent, int flags, int startId) {

		IntentFilter unlockFilter = new IntentFilter(Intent.ACTION_USER_PRESENT);
		registerReceiver(new UnlockReceiver(), unlockFilter);
		
		return START_STICKY;
	}

	/** A client is binding to the service with bindService() */
	@Override
	public IBinder onBind(Intent intent) {
		return mBinder;
	}

	/** Called when The service is no longer used and is being destroyed */
	@Override
	public void onDestroy() {
		// TODO Auto-generated method stub
	}
}




